package com.sccba.uop.demo.util;

import java.security.SecureRandom;
import java.util.UUID;

public class RandomUtils {

    private static final SecureRandom secureRandom = new SecureRandom();

    /**
     * 生成36位uuid
     *
     * @return
     */
    public static String uuid() {
        return UUID.randomUUID().toString();
    }

    /**
     * 生成不带横线的32位uuid
     *
     * @return
     */
    public static String uuidNonLine() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }

    /**
     * 截取32位以内长度的随机字符串
     * 超过32位
     *
     * @param size
     * @return
     */
    public static String uuidNonLine(int size) {
        String uuid = uuidNonLine();
        if (size >= 32) {
            return uuid;
        }
        return uuid.substring(0, size);
    }

}
